using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using UnityEngine;

public class Player
{
    public int age = 42;
    public string name = "asd";
    public Item item=new Item();

} 
public class Item
{
    public int id=123; 
    public string name="wq";
  
}
public class Xmlxuliehua : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Player p=new Player();  
        string path = Application.persistentDataPath + "/Lesson1Test.xml";
        print(Application.persistentDataPath);
        using (StreamWriter stream=new StreamWriter(path))
        {
            XmlSerializer xml = new XmlSerializer(typeof(Player));
            xml.Serialize(stream, p);
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
